<%@ page import="br.com.qualityempresa.seguranca.AutenticacaoUtils"%>
<%@ page import="br.com.qualityempresa.seguranca.Usuario"%>
<%@ page import="br.com.qualityempresa.seguranca.Perfil"%>

<div class="row">

	<div class="span3 control-group ${hasErrors(bean: usuarioInstance, field: 'nome', 'error')} ">
		<label class="control-label" for="nome">
			<g:message code="usuario.nome.label" default="Nome" />
		</label>
		<g:textField class="span3" name="nome" value="${usuarioInstance?.nome}" autofocus="true" />
	</div>

	<div class="span3 control-group ${hasErrors(bean: usuarioInstance, field: 'email', 'error')} required">
		<label class="control-label" for="email">
			<g:message code="usuario.email.label" default="Email" />
			<span class="required-indicator">*</span>
		</label>
		<g:field class="span3" type="email" name="email" required="" value="${usuarioInstance?.email}" />
	</div>

</div>

<div class="row">

	<div class="span2 control-group ${hasErrors(bean: usuarioInstance, field: 'senha', 'error')} required">
		<label class="control-label" for="senha">
			<g:message code="usuario.senha.label" default="Senha" />
			<span class="required-indicator">*</span>
		</label>
		<g:field class="span2" type="password" name="senha" required="" value="${usuarioInstance?.senha}" />
	</div>

	<div class="span2 control-group ${hasErrors(bean: usuarioInstance, field: 'validarSenha', 'error')} ">
		<label class="control-label" for="validarSenha">
			<g:message code="usuario.validarSenha.label" default="Validar Senha" />
		</label>
		<g:field class="span2" type="password" name="validarSenha" value="${usuarioInstance?.validarSenha}" />
	</div>

	<g:permissao devePossuir="true" controles="usuario" acoes="alterarPerfil">
		<div class="span2 control-group ${hasErrors(bean: usuarioInstance, field: 'perfil', 'error')} ">
			<label class="control-label" for="perfil">
				<g:message code="usuario.perfil.label" default="Perfil" />
			</label>
			<g:permissao devePossuir="false" controles="usuario" acoes="listarPerfisInvisiveis">
					<g:select class="span2" name="perfil.id" from="${Perfil.findAllByVisivel(true)}" value="${usuarioInstance?.perfil?.id}" optionValue="nome" optionKey="id" />
				</g:permissao> 
			<g:permissao devePossuir="true" controles="usuario" acoes="listarPerfisInvisiveis">
				<g:select class="span2" name="perfil.id" from="${Perfil.list()}" value="${usuarioInstance?.perfil?.id}" optionValue="nome" optionKey="id" />
			</g:permissao>
		</div>
	</g:permissao>

</div>
<%----%>
<%--<div class="row">--%>
<%----%>
<%--	<div class="span2 control-group ${hasErrors(bean: usuarioInstance, field: 'ativo', 'error')} ">--%>
<%--		<label class="control-label" for="ativo">--%>
<%--			<g:checkBox name="ativo" value="${usuarioInstance?.ativo}" />--%>
<%--			<g:message code="usuario.ativo.label" default="Ativo" />--%>
<%--		</label>--%>
<%--	</div>--%>
<%----%>
<%--</div>--%>